import request from '@/utils/request'

const prePath = '/contract'

//合同新增
export function createContract(data) {
  return request({
    url: prePath,
    method: 'post',
    data,
  })
}
export function createContractAndSave(data) {
  return request({
    url: prePath + '/saveAndSubmit',
    method: 'post',
    data,
  })
}
//合同修改
export function updateContract(data) {
  return request({
    url: prePath,
    method: 'put',
    data,
  })
}
//合同停启用
export function changeStatusContract(data) {
  return request({
    url: prePath + '/changeStatus',
    method: 'post',
    data,
  })
}
// 合同分页查询
export function getContractCustomizeListPage(data) {
  return request({
    url: prePath + '/customizeList/page',
    method: 'post',
    data,
  })
}
export function getSpdContractCustomizeListPage(data) {
  return request({
    url: '/spd/contract/customizeList/page',
    method: 'post',
    data,
  })
}
export function getContractPage(params) {
  return request({
    url: prePath + '/page',
    method: 'get',
    params,
  })
}
// 合同分页查询
export function getQuoteContractDetailListPage(data) {
  return request({
    url: prePath + '/details/selectForQuote',
    method: 'post',
    data,
  })
}

// 合同全部查询
export function getContractCustomizeListAll(data) {
  return request({
    url: prePath + '/customizeList/all',
    method: 'post',
    data,
  })
}

// 合同分页查询
export function getContractCustomizeGroups(data) {
  return request({
    url: prePath + '/customizeGroups',
    method: 'post',
    data,
  })
}

//获取合同详情
export function selectContractById(id) {
  return request({
    url: prePath + '/' + id,
    method: 'get',
  })
}

// 合同提交
export function submitContract(data) {
  return request({
    url: prePath + '/submit',
    method: 'post',
    data,
  })
}

// 合同审核
export function checkContract(data) {
  return request({
    url: prePath + '/check',
    method: 'post',
    data,
  })
}

// 合同删除
export function deleteContract(data) {
  return request({
    url: prePath,
    method: 'delete',
    data,
  })
}

// 合同撤回
export function revokeContract(data) {
  return request({
    url: prePath + '/revoke',
    method: 'post',
    data,
  })
}
// 合同驳回
export function rejectContract(data) {
  return request({
    url: prePath + '/reject',
    method: 'post',
    data,
  })
}
// 合同分页查询
export function getContractDetailCustomizeListPage(data) {
  return request({
    url: prePath + '/details/customizeList/page',
    method: 'post',
    data,
  })
}

// 合同全部查询
export function getContractDetailCustomizeListAll(data) {
  return request({
    url: prePath + '/details/customizeList/all',
    method: 'post',
    data,
  })
}

export function getContractProductDetailCustomizeListAll(data) {
  return request({
    url: prePath + '/productDetails/customizeList/all',
    method: 'post',
    data,
  })
}

// 合同分页查询
export function getContractDetailCustomizeGroups(data) {
  return request({
    url: prePath + '/details/customizeGroups',
    method: 'post',
    data,
  })
}

//打印申论详情
export function printContractList(data) {
  return request({
    url: prePath + '/printList',
    method: 'post',
    data,
  })
}

//打印申论详情
export function printContractDetail(data) {
  return request({
    url: prePath + '/printDetail',
    method: 'post',
    data,
  })
}

//导出合同列表
export function exportContractList(data) {
  return request({
    url: prePath + `/excelList`,
    method: 'post',
    data,
    responseType: 'blob',
  })
}

//导出合同明细
export function exportContractDetail(data) {
  return request({
    url: prePath + `/excelDetail`,
    method: 'post',
    data,
    responseType: 'blob',
  })
}

//导出合同明细列表
export function exportContractDetailList(data) {
  return request({
    url: prePath + `/details/excel`,
    method: 'post',
    data,
    responseType: 'blob',
  })
}

export function printContractDetailList(data) {
  return request({
    url: prePath + '/details/print',
    method: 'post',
    data,
  })
}

//获取合同付款明细
export function getContractPayDetailByOrderId(params) {
  return request({
    url: prePath + '/payDetail/all',
    method: 'get',
    params,
  })
}

//获取合同验收项目明细
export function getContractAcceptanceDetailByOrderId(params) {
  return request({
    url: prePath + '/acceptanceDetail/all',
    method: 'get',
    params,
  })
}

//获取待审核合同列表
export function getSlipContractPage(params) {
  return request({
    url: prePath + '/slipContractPage',
    method: 'get',
    params,
  })
}
export function downloadContract(data) {
  return request({
    url: prePath + '/customizeList/download/file',
    method: 'post',
    responseType: 'blob',
    data,
  })
}

//根据合同绑定产品
export function getProductByContract(params) {
  return request({
    url: prePath + '/productDetails/merge',
    method: 'get',
    params,
  })
}

//查询合同列表
export function getContractList(params) {
  return request({
    url: prePath + '/selectContractForPurch',
    method: 'get',
    params,
  })
}
//获取待收货入库合同
export function getPendDealContractPage(params) {
  return request({
    url: prePath + '/getPendDealContractPage',
    method: 'get',
    params,
  })
}
